package cn.itsource.zcn.org.mapper;

import cn.itsource.zcn.org.domain.Shop;
import cn.itsource.zcn.org.query.ShopQuery;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * (Shop)表数据库访问层
 *
 * @author makejava
 * @since 2021-08-13 19:46:51
 */
public interface ShopMapper {

    /**
     * 新增数据
     *
     * @param tShop 实例对象
     */
    @Insert("insert into t_shop" +
            "(name,tel,registerTime,state,address,logo,admin_id)" +
            "values (#{name},#{tel},#{registerTime},#{state},#{address},#{logo},#{admin.id})")
    void save(Shop tShop);

    /**
     * 修改数据
     *
     * @param tShop 实例对象
     */
    @Update("update t_shop set " +
            "name=#{name},tel=#{tel},registerTime=#{registerTime},state=#{state},address=#{address},logo=#{logo},admin_id=#{admin_id} " +
            "where id = #{id}")
    void update(Shop tShop);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     */
    @Delete("delete from t_shop where id = #{id} ")
    void delete(Long id);


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Select("select * from t_shop where id = #{id}")
    Shop queryById(Long id);

    /**
     * 查询全部
     *
     * @return 对象列表
     */
    @Select("select * from t_shop")
    List<Shop> queryAll();

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<Shop> 实例对象列表
     */
    void insertBatch(@Param("Shops") List<Shop> entities);

    /**
     * 批量删除数据（MyBatis原生foreach方法）
     *
     * @param ids List<Integer> 实例对象列表
     */
    void deleteBatch(@Param("ids") List<Integer> ids);

    /**
     * 数量
     * @param shopQuery
     * @return
     */
    Integer count(ShopQuery shopQuery);

    /**
     * 分页+高级
     * @param shopQuery
     * @return
     */
    List<Shop> page(ShopQuery shopQuery);
    @Select("select * from t_shop where admin_id = #{id}")
    Shop queryByAdminid(Long id);
}

